﻿using System.Threading.Tasks;

namespace PLCS.App.ProcessSolution.ViewModels.Process;

public class ProcessViewModel : NavigationPagedCurdViewModel<ProcessDto, ProcessEditDto, IProcessService>
{
    private string _processNo;

    public string ProcessNo
    {
        get { return _processNo; }
        set { SetProperty(ref _processNo, value); }
    }

    public ProcessViewModel(IProcessService service) : base(service)
    {
    }

    public override async Task GetPageData(int pageIndex)
    {
        try
        {
            UpdateLoading(true);
            var res = await _service.GetListBySearchAsync((pageIndex - 1) * PageSize, PageSize, ProcessNo);
            TotalCount = (int)res.TotalCount;
            SetPageCount();
            DataGridList = res.Items.ToObservable();
        }
        finally
        {
            UpdateLoading(false);
        }
    }
}